/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rw.magallanes.ide.main;

import java.io.FileInputStream;
import java.util.Properties;

/**
 *
 * @author Gonzalez
 */
public class Configuration {

    private static Configuration instance;
    private String CONFIGURATION_FILE = "conf.properties";
    private Properties properties = new Properties();
    // keys
    private String KEY_LAST_FOLDER = "key.last.folder";

    private Configuration() {
        try {
            FileInputStream fis = new FileInputStream(CONFIGURATION_FILE);
            properties.load(fis);
        } catch (Exception e) {
            System.out.println("Cargando configuraciones por defecto");
            loadDefaults();
        }
    }

    public static Configuration getInstance() {
        instance = instance == null ? new Configuration() : instance;
        return instance;
    }

    private void loadDefaults() {
        properties.setProperty(KEY_LAST_FOLDER, "");
    }

    public void setProperty(String key, String value) {
        properties.setProperty(key, value);
    }
}
